/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * <p>Project: javase - List2
 * <p>Powered by webrx On 2021-12-08 19:23:44
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class List2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.clear();
        System.out.println(list.size());
        list.add("html");
        list.add(0, "javascript");
        list.addAll(Arrays.asList("java", "mysql", "redis", "springmvc"));
        list.addAll(list.indexOf("java"), Arrays.asList("aaaa", "bbbb", "cccc"));
        System.out.println(list.containsAll(Arrays.asList("aaaa", "bbbb", "cccc")));
        list.add("aaaa");
        list.add("java10");
        list.add("java17.0.1");

        //删除指定的集合元素全部删除
        list.removeAll(Arrays.asList("aaaa", "bbbb", "cccc"));
        list.removeAll(Arrays.asList("aaaa", "bbbb", "cccc"));
        //删除java开头的对象
        //list.removeIf(e -> e.startsWith("java"));
        System.out.println(list);

        list.forEach(System.out::println);
        list.addAll(0, List.of("a1", "a2", "a3", "a4"));
        list.addAll(List.of("a1", "a2", "a3", "a4"));
        list.removeAll(List.of("a1", "a2", "a3", "a4"));
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }

        list.replaceAll(e -> e.startsWith("java") ? "hello:".concat(e) : e);
        System.out.println(list);


    }
}
